package com.magina.antiPro.pdfData;

import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;


public class CreatePdfDemo {
    public static void main(String[] args) throws FileNotFoundException, DocumentException {
        createPdf();
    }

    private static String FILE_DIR  = "../data/";

    public static void createPdf() throws DocumentException, FileNotFoundException {
        //Step 1—Create a Document.
        Document document = new Document();
//Step 2—Get a PdfWriter instance.
        PdfWriter.getInstance(document, new FileOutputStream(FILE_DIR + "createSamplePDF.pdf"));
//Step 3—Open the Document.
        document.open();
//Step 4—Add content.
        document.add(new Paragraph("Hello World"));
//Step 5—Close the Document.
        document.close();
    }
}
